/**
 * 
 */
package gpl.scotlandyard.android.activities;

import gpl.scotlandyard.android.R;
import gpl.scotlandyard.android.controllers.PathFinderController;
import android.content.Context;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.EditText;

/** @author norbert */
public class PathFinderActivity extends AbstractActivity {

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.path_finder);
    setController(PathFinderController.getInstance());
    getController().setActivity(this);

    Button but = (Button) findViewById(R.id.pathFinder_searchPaths);
    but.setOnClickListener(new OnClickListener() {
      @Override
      public void onClick(View v) {
        String fugIn = ((EditText) findViewById(R.id.pathFinder_fugitive_position_input)).getText().toString();
        String detIn = ((EditText) findViewById(R.id.pathFinder_detective_positions_input)).getText().toString();
        InputMethodManager inputManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
        inputManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
        getController().searchPaths(fugIn, detIn);
      }
    });
    getController().onViewCreated();
  }

  @Override
  public PathFinderController getController() {
    return (PathFinderController) super.getController();
  }

  @Override
  protected void onCreateOptionsMenuChild(Menu menu) {
    // do nothing
  }

  @Override
  protected boolean onOptionsItemSelectedChild(MenuItem item) {
    // do nothing
    return false;
  }

}
